<%-- 
    Document   : register
    Created on : Jul 27, 2012, 11:28:12 AM
    Author     : Admin
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ page language="java" import="captchas.CaptchasDotNet" %>
<!DOCTYPE html>
<html>
<head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Register</title>
<script type="text/javascript">
function PasswordFunction(){
	var user=document.myForm.login.value;
	var pw=document.myForm.pw.value;
        var comfirm_pw=document.myForm.pw2.value;
	var letters=/^[A-Za-z]+$/;
	var LetterAndDigit =/[^A-Za-z0-9 ]/;
	var digit=/\d/;
	var OneLetter=/[a-zA-Z]/;
        var email = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i;

	//var letter=pw.replace(/[^A-Z]/gi, "").length;
	if (pw.length<5 || pw.length > 7){
		alert("Please Enter a password with length between 5 to 7");
	    document.myForm.pw.focus();
        return false;
	}
	else if(email.test(user)==false){
		alert("Please Enter a valid Email Address");
	    document.myForm.login.focus();
        return false;
	} 
	else if((LetterAndDigit.test(pw))) {
		alert("Password can only contain letters and digits");    
		document.myForm.pw.focus();
		return false;
	}
        
        else if(comfirm_pw != pw) {
		alert("Comfirm password does not match");    
		document.myForm.pw.focus();
		return false;
	}
        
	else if((OneLetter.test(pw) && digit.test(pw))==false) {
		alert("Password needs to have at least 1 letter and 1 digit");    
		document.myForm.pw.focus();
		return false;
	}
	else return true;
}
</script>

 <%
 // Construct the captchas object (Default Values)
 CaptchasDotNet captchas = new captchas.CaptchasDotNet(
   request.getSession(true),     // Ensure session
   "demo",                       // client
   "secret"                      // secret
   );
 %>

<style type="text/css">
.bg {
	background-color: #09F;
}
.formbg {
	background-color: #09F;
	width: auto;
	height: auto;
	box-sizing: content-box;
}
.tableb {
	background-color: #FFC;
	border-top-style: hidden;
	border-right-style: hidden;
	border-bottom-style: hidden;
	border-left-style: hidden;
}
</style>
</head>
<body class="bg">
<h1 align="center">&nbsp;	</h1>
<h1 align="center">&nbsp;</h1>
<h1 align="center"><em>register mylist account</em></h1>
<p>&nbsp;</p>
<form action="register" name="myForm" class="formbg" method="post">
<jsp:useBean id="user" scope="session" class="business.User"/>
  <div align="center">
    <table class="tableb">
       
      <tr><td>First Name:</td><td><input type="text" name="firstName" size="15"  
             value="<jsp:getProperty name="user" property="firstName"/>"></td></tr>
      
      <tr><td>Last Name:</td><td><input type="text" name="lastName" size="15"
             value="<jsp:getProperty name="user" property="lastName"/>"></td></tr>
      
      <tr><td>Email Address:</td><td><input  type="text" name="emailAddress" size="15"
             value="<jsp:getProperty name="user" property="emailAddress"/>"></td></tr>
      
     
      <tr><td>Password:</td><td><input type="password" size="15" name="pw" 
              value="<jsp:getProperty name="user" property="passWord"/>">
        <input type="hidden" name="string" value="secret"></td></tr>
      
   
      
      
      <tr><td>Comfirm Password:</td><td><input type="password" size="15" name="pw2"/> 
        <input type="hidden" name="string" value="secret"></td></tr>
      <tr><td>CAPTCHA password:</td><td><input type="text" size="15" name="CAPTCHA"/> 
      <tr>
         <td>
         </td>
         <td>
           <%= captchas.image() %><br>
           <a href="<%= captchas.audioUrl() %>">Phonetic spelling (mp3)</a>
         </td>
      
      <tr>
        <td>&nbsp;</td></tr>
    </table>
    <p>
      <input type="submit"  name="mysubmit" value="Register" onclick="return PasswordFunction()"/>
    </p>
  </div>    
</form>    
        
        
        

</body>
</html>
